var theIndex=0;
var theCurrentRow=null;
var strFrameName=null;

function SelectValue() 
{
 if (theCurrentRow==null)
 		return;
 var index;
 var returnArray=new Array();
 index=theCurrentRow.rowIndex;
 if (index>=0)
  { 
   for (var i=0;i<theCurrentRow.cells.length;i++)
   	 returnArray[i]=trim(theCurrentRow.cells(i).innerText);
     top.returnValue=returnArray;
     window.close();
  } 
 }
 
function getRelateData(theObj,isSelfCode)
{	
	var tempStr="",theFindStr="";
	var theLength=0;
	var isFind=false,isBack=false;
	
	strFrameName="leftFrame";
		
	var oTable=parent.frames(strFrameName).document.getElementById("ListTable");
	if (oTable.rows.length==0)
		return ;
	if (event.keyCode==8 || event.which==8)	//back space key
	{
		theIndex=0;	
		theCurrentRow=oTable.rows(0);
		changeRow(theCurrentRow);
	}
	
	if (theIndex==null)
	{
		theIndex=0;
		theCurrentRow=oTable.rows(0);
		changeRow(theCurrentRow);
	}
	if (event.keyCode==13 || event.which==13)//Enter Key
		SelectValue();
	else
	{
		tempStr=theObj.value;
		theLength=tempStr.length;	
		if (tempStr=="" || theLength==0)
		{
			theIndex=0;
			isFind=false;
			changeRow(theCurrentRow);
			return;
		}		
		while (!isFind && theIndex<oTable.rows.length && theIndex>=0)
		{			
			theCurrentRow=oTable.rows(theIndex);
			var sindex = document.getElementById("TypeList").selectedIndex;
			var hidenum = document.getElementById("hidecolnum").value;
			var index1 = parseInt(sindex)+parseInt(hidenum);
			theFindStr=trim(theCurrentRow.cells(parseInt(index1)).innerText);
			if (theFindStr.toUpperCase().substring(0,theLength)==tempStr.toUpperCase())
			{
				isFind=true;
				changeRow(theCurrentRow);
			}	
			if (isBack && theIndex>0)
				theIndex--;	
			else
				theIndex++;	
		}		
		theIndex=theCurrentRow.rowIndex;
	}
}

function changeRow(theCurr)
{
	if (parent.frames(strFrameName).preObj!=null)
		parent.frames(strFrameName).preObj.className="Normal";
	if (theCurr!=null)
		theCurr.className="Selected";
	parent.frames(strFrameName).preObj=theCurr;
	if (parent.frames(strFrameName).preObj!=null)
		parent.frames(strFrameName).preObj.scrollIntoView();
}